In this video, I'm going to modify a part size and position with the script.
So I'm going to introduce a new row box data type called a vector three vector threes are great for
holding three numbers.
Let's go ahead and see how that's done.
I have my first game right here because it's convenient.
You can go ahead and get a fresh world, but make sure there's a part in it.
If there is a part in it, open that part up and then disable any scripts that we might have done from
other videos.
So I'm just going to disable change it.
Let's go to my part and we'll add a script here, but let's take a look at size and position.
I know this is a little bit small, but that's all right.
Go to properties, look for size and position, hit the little arrow and you'll notice there's an X,
Y and Z.
That is for the length, the height and the width, right?
X, Y and Z.
If you want to know which is which, you'll have a little x right here.
It's hard to see the key there, a z, and then the Y is the up and down.
So that's a little key on where your X, Y and Z is and which way you're going.
If we look at position, we have this crazy decimal number here for X and Z because we just plopped
it in the world.
10.5 is the height, the terrain is ten studs height, and then the block is one stud.
So halfway through is the position.
The position is going to be in the center of the part.
So this is touching the ground if we move our Z.
Let's go ahead and take a look at that.
We have a -13.305 or something, something kind of crazy.
Let's make it a zero boom.
We just moved it along the Z.
See, there's your Z.
Cool.
Let's go ahead and do that with a script, though.
All right, so on my part, let's hit the little plus sign.
Boom!
Open it up.
I had a script and that in the script, let's say let's call this move it.
We're actually going to move it and change the size.
But the script is descriptive enough so you know how to find it if you need to.
And we only have four scripts.
Let's get rid of that print and then we'll do a local part equals script.
So we just got a variable for our part.
There's a script.
There's the parent.
My part is sitting right in there.
All right.
Let's go ahead and wait 6 seconds, because we're going to change the position of our part and we want
to see it.
And it takes a little bit of time for the game to start up.
We don't want to miss it.
Let's get our part.
Dot position.
There it is.
I put a P there.
There's position.
What is position?
Check this out.
If we do that p again hit position, we see this vector three.
Oh, it's giving us a hint.
That's the data type.
That's the data type we need factor three.
Hold three numbers.
We need three numbers an, x, y and Z.
We had vector three on this side of the plus sign or the equal sign enter new.
We are instantiating a new vector three.
That's the fancy way of saying it.
So we're creating a vector three.
That's the normal way of saying it.
How shall we move this?
It was something crazy.
It was like we had our part.
Let's take a look.
Position was 26 point something.
10.5.
And we made that last.
That last value is zero.
Let's make it 40 studs on the x 10.5.
We're going to keep it the same height.
Keep it the same Z.
Let's see what we got.
Let's go to my first game.
Hit play.
And watch it move.
BO.
That was that was kind of cool.
Let's let's make a move some more, though.
We'll hit the stop.
Mauve.
And then we'll get this.
Let's get these two lines.
You can do a control C to copy or you use the mouse right click and then use the menu.
I'm going to do a control V to paste.
Let me make this one second and let's see.
Let's make this 30.
There we go.
30.
Let's do that a couple of times.
I still have those two lines of code in my my buffer.
I'm going to do a control v control v control v.
We'll move it a few times.
Let's see.
We got let's make this one second.
And then we'll go to 20.
Cool.
Let's do one second.
We'll go to.
20 again.
Should we do 20 again and then maybe change the Z a little bit?
Let's change the Z to like.
Ten.
All right.
And then.
Let's do something a little different.
Like with a height.
Let's go one second and then the height.
Let's move this up to studs.
But we'll keep in the same position.
We'll do 20 12.5 and it's supposed to be a ten.
Cool.
Let's see what we got.
There we go.
Yeah.
On it fell.
Did you see how it went up and then it fell?
Well, we can fix that.
We can anchor this part.
Anchoring a part will do control.
Just move that anchor.
Anchoring a part will prevent your part from moving from game objects in the game.
But you can still move it with a script.
You need to know that.
Let's go ahead and anchor this so that when we move it, the game forces won't take over like gravity
pulling it down once we move it up.
Hit that little checkbox.
Hit play.
And then watch our part.
It's going to be pretty exciting.
One, two, three, four, up.
Look at that.
It's just hanging in the air.
You can make a staircase with code.
Oh, man.
Cool.
Let's change the size just so you get a feel for that.
This is our spawn location.
We can move that.
There we go.
Good to move it and let's change the size now.
Control C to copy.
Control V to paste.
This is going to be size or that size.
Size also wants a vector three.
The IntelliSense is up here.
Let's just go ahead and click it.
I was kind of hard to read.
I no remember our size.
Now, if we click click our my part, let's look at size is four one and two.
So we don't want to make it this big.
Let's make it four, four and four.
Sweet play.
It's going to be exciting.
One, two, three, four.
Boom!
Oh, look at that.
That made it big.
That's kind of cool.
All right.
So one other thing I want to show you is we have other values that hold vector threes.
In particular, we have orientation, which affects the rotation of the object.
And these Z, the X, Y and Z is going to be the axes of rotation.
This will be in degrees.
We're going to go over that with our rotating coin.
I have a rotating coin, one I also want to show you in the browser.
I'll put this link in the description.
You can go ahead and take a look at ROBLOX engine data types, ROBLOX Engine data types and vector three
is down here, so you can read more about it.
It's good to start looking at the documentation because you can't always find everything in a video.
So with that I will see you in the next video.